<?php

namespace common\models\base;

use Yii;

/**
 * This is the model class for table "{{%edivi_credit_order_users_pics}}".
 *
 * @property int $id
 * @property int $edivi_credit_order_user_id
 * @property int $edivi_cl_id
 * @property int $edivi_yp_id
 * @property string $pic_id
 * @property string $pic_code
 * @property string $pic_file_name
 * @property string $pic_address
 *
 * @property EdiviOrderYpbl $ediviYp
 * @property EdiviCreditOrderUsers $ediviCreditOrderUser
 * @property EdiviOrderClbl $ediviCl
 */
class EdiviCreditOrderUsersPics extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%edivi_credit_order_users_pics}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['edivi_credit_order_user_id', 'edivi_cl_id', 'edivi_yp_id'], 'integer'],
            [['pic_id', 'pic_code', 'pic_file_name', 'pic_address'], 'required'],
            [['pic_id', 'pic_code'], 'string', 'max' => 20],
            [['pic_file_name'], 'string', 'max' => 300],
            [['pic_address'], 'string', 'max' => 500],
            [['edivi_yp_id'], 'exist', 'skipOnError' => true, 'targetClass' => EdiviOrderYpbl::className(), 'targetAttribute' => ['edivi_yp_id' => 'id']],
            [['edivi_credit_order_user_id'], 'exist', 'skipOnError' => true, 'targetClass' => EdiviCreditOrderUsers::className(), 'targetAttribute' => ['edivi_credit_order_user_id' => 'id']],
            [['edivi_cl_id'], 'exist', 'skipOnError' => true, 'targetClass' => EdiviOrderClbl::className(), 'targetAttribute' => ['edivi_cl_id' => 'id']],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'edivi_credit_order_user_id' => Yii::t('app', 'Edivi Credit Order User ID'),
            'edivi_cl_id' => Yii::t('app', 'Edivi Cl ID'),
            'edivi_yp_id' => Yii::t('app', 'Edivi Yp ID'),
            'pic_id' => Yii::t('app', 'Pic ID'),
            'pic_code' => Yii::t('app', 'Pic Code'),
            'pic_file_name' => Yii::t('app', 'Pic File Name'),
            'pic_address' => Yii::t('app', 'Pic Address'),
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviYp()
    {
        return $this->hasOne(EdiviOrderYpbl::className(), ['id' => 'edivi_yp_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviCreditOrderUser()
    {
        return $this->hasOne(EdiviCreditOrderUsers::className(), ['id' => 'edivi_credit_order_user_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getEdiviCl()
    {
        return $this->hasOne(EdiviOrderClbl::className(), ['id' => 'edivi_cl_id']);
    }
}
